package php.code.routines;

import utils.titles.Title;
import php.code.indentation.Indentable;
import php.code.instructions.VariableDeclaration;
import php.code.statements.Statement;

public abstract class Routine extends Statement {
    private final Title title;

    @Override
    protected boolean useBrackets() {
        return true;
    }

    public Routine(Indentable parent, Title title) {
        super(parent, true);
        this.title = title;
    }

    public Routine(Title title) {
        super(true);
        this.title = title;
    }

    public Title getTitle() {
        return title;
    }

    public VariableDeclaration declareVar(Title name, int pad, String value) {
        VariableDeclaration var = new VariableDeclaration(name, pad, value + ";");
        block.add(var);
        return var;
    }

    public VariableDeclaration declareVar(Title name, String value) {
        return declareVar(name, 0, value);
    }

    public String getName(){
        return getTitle().toLowerCamel();
    }

    public VariableDeclaration declareVar(Title title) {
        return declareVar(title, null);
    }
}
